import { createRouter, createWebHistory } from 'vue-router';

const routes = [
  {
    path: '/',
    name: 'Index',
    component: () => import("../views/index.vue"),
    meta: { title: '1' }
  },
  // 可以添加更多路由配置
];

const router = createRouter({
  history: createWebHistory(),
  routes
});

/**
 * 路由守卫
 */

import store from '../store';

router.beforeEach((to, _from, next) => {
  const token = to.query.token;
  if (token) {
    store.commit('setToken', token);
  }
  next();
});
router.afterEach((_to) => {
  // 可以在这里进行一些页面切换后的操作
});


export default router;